package com.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.javabean.SysLog;
import com.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author: 张波
 * @Time: 2025/8/29 11:20
 */
@Controller
@RequestMapping("/syslog")
public class SysLogController {

	@Autowired
	SysLogService sysLogService;

	@RequestMapping("/findAll")
	public String findAll(HttpServletRequest request, @RequestParam(value = "page",defaultValue = "1") int page, @RequestParam(value = "limit",defaultValue = "5")  int limit, @RequestParam(value = "username",defaultValue = "") String username, @RequestParam(value = "url",defaultValue = "")  String url){
		PageHelper.startPage(page,limit);
		List<SysLog> all = sysLogService.findAll(username, url);
		PageInfo<SysLog> pageInfo=new PageInfo<>(all);
		request.setAttribute("pageInfo",pageInfo);
		request.setAttribute("username",username );
		request.setAttribute("url",url );
		return "/syslog/syslog-list";
	}
}